package cn.news.controller;

import cn.news.pojo.Detail;
import cn.news.service.CategoryService;
import cn.news.service.DetailService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import redis.clients.jedis.Jedis;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class NewsController {

    @Resource
    private CategoryService cs;

    @Resource
    private DetailService ds;

    @RequestMapping("/getNews")
    @ResponseBody
    public List getNew(Integer cId,String title){
        return  ds.getNews(cId,title);
    }

    @RequestMapping("/getType")
    @ResponseBody
    public List getType(){
        List list=cs.getType();
        return list ;
    }

    @RequestMapping("/toUpdate")
    @ResponseBody
    public Detail toUpdate(Integer id){

        return  ds.getById(id);
    }

    @RequestMapping("/update")
    @ResponseBody
    public int update(Detail d){
        int count=ds.update(d);
        return  count;
    }



}
